#include<stdio.h>
int main()
{   int i,s=1,x,m,n,sum=0,h;
    int a[3];    
    scanf("%d",&x);
    m=x;
	for (i=0;i<=s;i++)
	{
		s=s+i;
		h=m;
		m=m/8;
		a[i]=h%8;
		if(m=0){
			n=i;
			break;
		}
	}
	for (i=n;i>=0;i--)
	{
		sum=sum+a[i]*10^i;
	}
	printf("%d",sum);
	return 0;
}
